<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

//use Illuminate\Routing\Router;
use Illuminate\Support\Facades\Route;

use Illuminate\Support\Facades\Auth;


//Route::get('/', function () {
//    return view('welcome');
//});

Auth::routes();

Route::get('/', 'HomeController@index')->name('home');
Route::get('/goods/show', 'GoodsController@show')->name('goods.show');
Route::get('/goods', 'GoodsController@index')->name('goods');
Route::get('/goods/match', 'GoodsController@match')->name('goods.match');


Route::get('/home', 'CategoryController@store');


Route::group(['middleware' => ['web', 'auth'], 'prefix' => ''], function () {
    Route::get('/goods/cart', 'CartController@store')->name('goods.cart');
    Route::get('/address/create', 'Admin\AddressController@create')->name('address.create');
    Route::post('/address/store', 'Admin\AddressController@store')->name('address.store');
    Route::get('/order/create', 'OrderController@create')->name('order.create');
    Route::post('/order/store', 'OrderController@store')->name('order.store');
    Route::get('/order', 'OrderController@index')->name('order.index');
    Route::get('/order/show', 'OrderController@show')->name('order.show');
    Route::post('/order/pay', 'OrderController@pay')->name('order.pay');
    Route::get('/order/pay', 'OrderController@payView')->name('order.pay_view');
    Route::post('/order/complete', 'OrderController@complete')->name('order.complete');
    Route::post('/cart/store', 'CartController@store')->name('cart.store');
    Route::post('/cart/check', 'CartController@check')->name('cart.check');
    Route::get('/cart', 'CartController@index')->name('cart.index');
    Route::get('/cart/list', 'CartController@getList')->name('cart.list');
    Route::post('/cart/multiple_check', 'CartController@multipleCheck')->name('cart.multiple_check');
    Route::post('/comment/store', 'CommentController@store')->name('comment.store');
    Route::post('/comment/list', 'CommentController@getList')->name('comment.list');
});

Route::group(['middleware' => ['web'], 'namespace' => 'Admin', 'prefix' => 'admin'], function () {
    Route::get('/login', 'AuthController@loginForm')->name('admin.login_form');
    Route::post('/login', 'AuthController@login')->name('admin.login');
    Route::get('/logout', 'AuthController@logout')->name('admin.logout');
});
Route::group(['middleware' => ['web', 'auth:admin'], 'prefix' => 'admin'], function () {
    Route::get('/', 'Admin\OrderController@index')->name('admin');
    Route::get('/category', 'Admin\CategoryController@index')->name('admin.category');
    Route::post('/category/list', 'Admin\CategoryController@getList')->name('admin.category.list');
    Route::get('/category/create', 'Admin\CategoryController@create')->name('admin.category.create');
    Route::post('/category/store', 'Admin\CategoryController@store')->name('admin.category.store');
    Route::post('/category/update', 'Admin\CategoryController@update')->name('admin.category.update');
    Route::post('/category/destroy', 'Admin\CategoryController@destroy')->name('admin.category.destroy');
    Route::get('/goods', 'Admin\GoodsController@index')->name('admin.goods');
    Route::get('/goods/detail', 'Admin\GoodsController@detail')->name('admin.goods.detail');
    Route::get('/goods/create', 'Admin\GoodsController@create')->name('admin.goods.create');
    Route::post('/goods/list', 'Admin\GoodsController@getList')->name('admin.goods.list');
    Route::post('/goods/store', 'Admin\GoodsController@store')->name('admin.goods.store');
    Route::post('/goods/destroy', 'Admin\GoodsController@destroy')->name('admin.goods.destroy');
    Route::get('/order', 'Admin\OrderController@index')->name('admin.order');
    Route::get('/order/show', 'Admin\OrderController@show')->name('admin.order.show');
    Route::post('/order/list', 'Admin\OrderController@getList')->name('admin.order.list');
    Route::post('/order/ship', 'Admin\OrderController@ship')->name('admin.order.ship');
    Route::get('/comments', 'Admin\CommentController@index')->name('admin.comments');
    Route::post('/comments/list', 'Admin\CommentController@getList')->name('admin.comments.list');
    Route::post('/comments/destroy', 'Admin\CommentController@destroy')->name('admin.comments.destroy');
    Route::post('/upload/file', 'Admin\UploadController@file')->name('admin.upload.file');

});
